package com.aibaixun.web.controller.system;

import com.aibaixun.common.config.ValidGroup;
import com.aibaixun.common.core.domain.R;
import com.aibaixun.system.domain.PostureDeviceModel;
import com.aibaixun.system.domain.dto.PostureDeviceModelPageDto;
import com.aibaixun.system.service.PostureDeviceModelService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * U模型数据管理模块
 *
 * @author zhangyh
 * @date 2023-09-01
 **/
@RestController
@RequestMapping("/posture/device/model" )
public class PostureDeviceModelController {

    @Autowired
    private PostureDeviceModelService postureDeviceModelService;

    /**
     * 分页查询模型
     * @return
     */
    @ApiOperation(value = "分页查询模型")
    @PostMapping("/page")
    public R<Page<PostureDeviceModel>> getPage(@RequestBody PostureDeviceModelPageDto pageDto){
        Page page = new Page();
        page.setCurrent(pageDto.getCurrent());
        page.setSize(pageDto.getSize());
        page.setSearchCount(true);
        return postureDeviceModelService.getPage(page, pageDto);
    }

    /**
     * 查询模型列表
     * @return
     */
    @ApiOperation(value = "查询模型列表")
    @PostMapping("/list")
    public R<List<PostureDeviceModel>> getList(@RequestBody PostureDeviceModel dto){
        return postureDeviceModelService.getList(dto);
    }

    /**
     * 新增模型
     * @return
     */
    @PostMapping("/add")
    public R add(@RequestBody @Validated(ValidGroup.Add.class) PostureDeviceModel dto) {
        return postureDeviceModelService.add(dto);
    }

    /**
     * 更新模型
     * @return
     */
    @PostMapping("/update")
    public R update(@RequestBody @Validated(ValidGroup.Update.class) PostureDeviceModel dto) {
        return postureDeviceModelService.update(dto);
    }

    /**
     * 删除模型
     * @return
     */
    @GetMapping("/delete/{modelId}")
    public R delete(@PathVariable(value = "modelId") Long modelId) {
        return postureDeviceModelService.delete(modelId);
    }

}
